<?php
session_start();
include 'mysql.php';
if(isset($_GET['unset'])&&$_GET['unset'])
{
    session_destroy();
    header("Location: /");
}

$month_array = array('01'=>'Jan','02'=>'Feb','03'=>'Mar','04'=>'Apr','05'=>'May','06'=>'Jun','07'=>'Jul','08'=>'Aug','09'=>'Sep','10'=>'Oct','11'=>'Nov','12'=>'Dec');
$year = date('Y',time());
$month  = $month_array[date('m',time())];
$day = date('d',time());


//  所有活动
$activity_list = array() ;
$result = $mysqli->query("select * from activity");
while($row =$result->fetch_array() ){
    $activity_list[] = $row;
}

// 所有活动照片

$photo_list = array() ;
$result = $mysqli->query("select * from photo");
while($row =$result->fetch_array() ){
    $photo_list[] = $row;
}

?>
<!DOCTYPE html>
<html>
	<head>
		<!-- Title here -->
		<title>Your Title</title>
		<!-- Description, Keywords and Author -->
         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="description" content="Your description">
		<meta name="keywords" content="Your,Keywords">
		<meta name="author" content="ResponsiveWebInc">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,600,700' rel='stylesheet' type='text/css'>
		<link href='http://fonts.googleapis.com/css?family=Lobster+Two:700' rel='stylesheet' type='text/css'>
		<link href='http://fonts.googleapis.com/css?family=Droid+Serif:400,400italic' rel='stylesheet' type='text/css'>
		
		<!-- Styles -->
		<!-- Bootstrap CSS -->
		<link href="css/bootstrap.min.css" rel="stylesheet">
		<!-- FlexSlider -->
		<link href="css/flexslider.css" rel="stylesheet">
		<!-- Font awesome CSS -->
		<link href="css/font-awesome.min.css" rel="stylesheet">		
		<!-- Custom CSS -->
		<link href="css/style.css" rel="stylesheet">
		
		<!-- Favicon -->
		<link rel="shortcut icon" href="#">

        	<!-- Javascript files -->
		<!-- jQuery -->
		<script src="js/jquery.js"></script>
		<!-- Bootstrap JS -->
		<script src="js/bootstrap.min.js"></script>
		<!-- FlexSlider -->
		<script src="js/jquery.flexslider-min.js"></script>
		<!-- jQuery Anchor Plugin -->
		<script src="js/jquery.anchor.js"></script>
		<!-- Respond JS for IE8 -->
		<script src="js/respond.min.js"></script>
		<!-- HTML5 Support for IE -->
		<script src="js/html5shiv.js"></script>
		<!-- Custom JS -->
		<script src="js/custom.js"></script>
		<script type="text/javascript">

        <?php if(isset($_SESSION['name'])&&!empty($_SESSION['name'])):?>
            var is_login = 1 ;
        <?php else:?>
            var is_login = 0 ;
        <?php endif;?>

		$(function(){

            $('.attend_button').click(function(){

                if(is_login=='0')
                {
                    alert('您尚未登录,不可以参加这个活动~');
                    return false ;
                }
                var type = $(this).attr('data');
                if(type=='1')
                {
                    alert('已经参加这个活动啦');
                    return false ;
                }
                else
                {
                    var number = $(this).children('span').text();
                    var new_num = parseInt(number)+1;
                    $(this).children('span').empty().text(new_num);
                    $(this).attr('data','1');
                }



            })

            $('form[name="form_submit"]').submit(function(){

                var name = $('#name').val();
                var password = $('#password').val();
                var attentive = $('#attentive').val();

                if(!name.length){
                    $('#name').focus();
                    return false ;
                }
                if(!password.length){
                    $('#password').focus();
                    return false ;
                }
                if(!attentive.length){
                    $('#attentive').focus();
                    return false ;
                }

            });
        })

		</script>
	</head>
	
	<body>
		<!-- Navigation Starts -->
		<div class="navbar navbar-default navbar-fixed-top bs-docs-nav" role="banner">
			<div class="container">
				<div class="navbar-header">
					<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".bs-navbar-collapse">
					  <span class="sr-only">Toggle navigation</span>
					  <span class="icon-bar"></span>
					  <span class="icon-bar"></span>
					  <span class="icon-bar"></span>
					</button>
					<a class="navbar-brand" href="#">Find &amp; The Passion</a>
				</div>
				
				<nav class="collapse navbar-collapse bs-navbar-collapse" role="navigation">
					<ul class="nav navbar-nav navbar-right">
						<li><a href="#home" class="anchorLink">主页</a></li>
						<li><a href="#about" class="anchorLink">关于我们</a></li>
						<li><a href="#photos" class="anchorLink">照片</a></li>
						<li><a href="#wedding" class="anchorLink">活动</a></li>
						<li><a href="#rsvp" class="anchorLink">房屋沟</a></li>
                        <?php if(isset($_SESSION['name'])&&!empty($_SESSION['name'])):?>
                            <li><a href="javascript:;" class="anchorLink">欢迎你,<?php echo $_SESSION['name'] ;?></a></li>
                            <li><a href="/index.php?unset=1" >退出</a></li>
                         <?php else:?>
                            <li><a href="#login" class="anchorLink" >登录</a></li>
                            <li><a href="/zhuce.php" >注册</a></li>
                        <?php endif;?>
                        <li><a href="admin.php" target="_blank">活动管理</a></li>
					</ul> 
				</nav>
				
		
			</div>
		</div>
		<a name="home" id="home"></a>
		<!-- Navigation Ends -->
		
		<!-- Main Starts -->
		<div class="main">
			<div class="container">
				<div class="row">
					<div class="col-md-8 col-sm-7">
						<div class="main-invite">
							<div class="signal"><i class="icon-signal"></i>	 <span>一起来</span></div>
							<h1>我们<br> 
								都在享受生活</h1>
							<p>享受生活，需要一种心境。平静地坐看时光流逝，平静地细数人世坎坷，这些都是享受生活的意境。生活的意义，不在权势和金钱，不在物质和名利，而在用一颗平淡无华的心情，去领悟生活中风雨兼程与风和日丽。</p>
						</div>
					</div>
					<div class="col-md-4 col-sm-5">
						<div class="main-date">
							<i class="icon-heart"></i>
							<div class="date"><span class="month"><strong><?php echo $day ;?>,<?php echo $month;?></strong></span><br><span class="year"><strong><?php echo $year;?></strong></span></div>
						</div>
					</div>
				</div>
				<a name="about" id="about"></a>
			</div>
		</div>
		<!-- About Starts -->
		<div class="about">
			<div class="container">
				<div class="row">
					<div class="col-md-12">
						<div class="title">
							<h3>关于我们</h3>
						</div>
						<div class="bor"></div>
						
						<p class="about-para text-center">我们是真诚的交友平台，我们为您提供最真诚的服务。你只需要放心大胆的加入我们，掏出你的真诚，我们一起来享受生活。</p>
						<div class="bor"></div>
					</div>
				</div>
		
				<div class="row">
					<div class="col-md-4 col-sm-4">
						<div class="groom">
							<h3>先生们</h3>
							<hr>
							<p class="text-center">一个中等身材的人，穿一套深色的英国式衣服，系一条新式的矮领带，一双羊皮鞋'他看来大约有三十几岁他的黄黄的，但是没有一条皱纹的 脸是特别地端正，而且轮廓非常清楚，就象是一把精巧的小凿子雕刻出来似的，在这张脸上还留着一种惊人之美的痕迹，那一对清明而漆黑的杏仁式样的眼睛尤其美。</p>
						</div>
					</div>
					<div class="col-md-4 col-sm-4">
						<div class="love">
							<i class="icon-heart"></i>
							<h3><?php echo $day ;?>,<?php echo $month;?> <?php echo $year;?></h3>
						</div>
					</div>
					<div class="col-md-4 col-sm-4">
						<div class="bride">
							<h3>女士们</h3>
							<hr>
							<p class="text-center">温柔的女人，不会过多的去矫饰自己的容颜，她们把更多的时间献给自己身边的人。尽管不再年轻，尽管时间的巨轮残酷地在那平滑的脸庞上碾下凌乱的皱颜，但温柔的女人依然是温温情情，真真切切，精精致致。她们的温柔比鲜花还要触动人心，她们的细心比鲜花还要清新，她们的善良比鲜花还要圣洁。</p>
						</div>
					</div>
				</div>
				<a name="photos" id="photos"></a>
				<hr>
			</div>
		</div>
		
		<!-- About Ends -->
		<!-- Photos Starts -->
		<div class="photos">
			<div class="container">
				<div class="row">
					<div class="col-md-12">
						<div class="title">
							<h3>照片集</h3>
						</div>
						
						<div class="bor"></div>
                  
						<div class="flexslider">
						  <ul class="slides">
                              <?php if(!empty($photo_list)&&isset($photo_list)):?>
                                  <?php foreach($photo_list as $val):?>
                                    <li>
                                      <img  width="850" height="400" src="<?php echo $val['url'];?>" alt=""  />
                                    </li>
                                  <?php endforeach;?>
                              <?php endif;?>
						  </ul>
						</div>
                  
					</div>
					
				</div>
				<a name="wedding" id="wedding"></a>
				<hr>
				
			</div>
		</div>
		
		<!--Photo Ends-->
		
		<!-- Wedding Starts -->
		<div class="wedding">
			<div class="container">
						<div class="title">
							<h3>活动介绍</h3>
						</div>
						<div class="bor"></div>
						
				<div class="row">
                    <?php if(!empty($activity_list)&&isset($activity_list)):?>
                    <?php foreach($activity_list as $val):?>
                    <div class="col-md-4 col-sm-4">
						<div class="well">
							<h3><i class="icon-heart"></i><?php echo $val['title']?></h3>
							<a href="#">发起人：<?php echo $val['name']?></a></br>
							<a href="#">手机号：<?php echo $val['mobile']?></a></br>
                             <img width="230" height="157"  src="<?php echo $val['cover']?>" alt="<?php echo $val['title']?>" />
					        <h5>活动细节</h5>
							<p><?php echo $val['desc']?></p>
							<a href="javascript:;" class="attend_button" data="0">快来加入吧(<span><?php echo rand(1,6);?></span>)</a>
						</div>
					</div>
                    <?php endforeach;?>
                    <?php endif;?>
				</div>
				<a name="rsvp" id="rsvp"></a>
				<hr>
				
			</div>
		</div>

        <a name="login" id="login"></a>
		<!-- Wedding Ends -->
		<?php if(!isset($_SESSION['name'])){?>
		<!-- RSVP Starts -->
		<div class="rsvp">
			<div class="container">
				<div class="title">
							<h3>快来登录吧</h3>
				</div>
				<div class="bor"></div>
				
				<div class="row">
					<div class="col-md-3 col-sm-3">
						<div class="heart">
							<i class="icon-heart"></i>
						</div>
					</div>
					<div class="col-md-6 col-sm-6">
						<div class="well">
							<p>在这里我们真诚交友，在这里我们共享生活，快来加入吧！我们一起共创美好幸福的生活。</p>
							<form class="form-horizontal" role="form"  name="form_submit" action="login.php" method="post">
							    <div class="form-group">
									<label class="control-form col-md-3" for="name">用户名</label>
									<div class="col-md-9">
										<input type="text" class="form-control" name="Form[name]" id="name" placeholder="请输入用户名">
									</div>
								</div>
								<div class="form-group">
									<label class="control-form col-md-3" for="email">密码</label>
									<div class="col-md-9">
										<input type="password" class="form-control" name="Form[password]" id="email"  placeholder="请输入密码">
									</div>
								</div>
								<div class="form-group">
									<label class="control-form col-md-3" for="attentive">参加吧？</label>
									<div class="col-md-9">
										<input type="text" class="form-control" name="Form[attentive]" id="attentive" placeholder="请输入参加理由">
									</div>
								</div>
								<div class="form-group">
									<div class="col-md-9 col-md-offset-3">
									<input type="submit" class="btn btn-danger" id="Submit" value="Submit">
									</div>
								</div>
							</form>
						</div>
					</div>
					<div class="col-md-3 col-sm-3">
						<div class="heart">
							<i class="icon-heart"></i>
						</div>
					</div>
				</div>
				<hr>
			</div>
		</div>
        <?php }?>
		<!-- RSVP Ends -->
		
		<!--Footer Starts -->
		<!--Footer Ends -->
		<span class="totop"><a href="#"><i class="icon-chevron-up"></i></a></span>
	</body>	
</html>

<?php $mysqli->close(); ?>